Lightweight C library to add web server functionality to your program

libonion is a lightweight library to help you create webservers in C programming language. These webservers may be a web application, a means of expanding your own application to give it web functionality or even a fully featured webserver.

The user can create new handlers that serve reading data from a file or creating them. However, there are many default handlers included to address the most frequently required needs.

The name libonion comes from the idea that the path transversal is being done using many layers of handlers: on one layer you set the auth control, on another you check the server hostname (so that you could have virtual hosts) and on yet another a regular expression sends you across to one or another path… Check on examples for how to do it.

For example a custom file server, with basic access permissions thought PAM (the standard Pluggable Permission Module used in almost all linux), is just 15 lines.

We have also an awesome web unix terminal at Onion Terminal.

It is actively developed and in use. Current code works perfectly on Intel processors (i386 and x86_64) and ARM processors. Other has not been tested but if there is a C compiler, high chances are that it will work.

Use cases

  • create new services that need small memory and CPU footprint because of the system characteristics, for example embeded systems,
  • small standalone web facing applications,
  • or just add http funcionality to already existing programs.

Thanks to otemplate and opack it is possible to embed all your code in a single executable, and thanks to crl developing is as fast as possible.

Go and test it!

Current users

Libonion has an extensive example portfolio with many simple and complex examples, but it is also used on real life:

  • Aisoy — Hardware platform for developing Artifical Intelligence applications. Here it is used to manage the communication with the bot, allowing to update the system software, and to deploy botapps (applications for this bot), and to interact with them. It also has a configuration area managed all this by onion. Thanks to the use of onion this project is only about 1000 lines of C code, the rest HTML and Javascript, about 500 more lines. Not bad. Less code, less errors. All in a nice 80kb ARM binary.

License

It is licensed under the LGPL v3, which means you can use, redistribute it and modify it. You can use it in free software and commercial programs. But if you modify something on the library itself, you must redistribute the changes to your users.

Download

All devlopment is performed on the open at Github. You can download onion from the github page: http://github.com/davidmoreno/onion. If you want to contribute, contributions are more than welcome.

API Documentation

Full API documentation is at https://www.coralbits.com/static/onion/

Consulting

If you have a project and you want to add the webserver functionality to it, we are eager to help you. Please contact us and sure we can join forces to get it running.

Send us an email now at dmoreno@coralbits.com, no compromises.